package com.red.star.wechat.data.mappers;

import com.red.star.wechat.data.entity.MerchantPoster;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MerchentH5Mapper {


    @Select("SELECT te.id AS employId FROM `t_employee` te WHERE te.fans_id = (SELECT tf.id FROM t_fans tf WHERE tf.open_id = #{openId}) AND te.`status` =0")
    Integer queryEmployeeIdByOpenId(String openId);

    @Insert("INSERT INTO stat_merchant_visit (open_id,ip,create_time) VALUES (#{openId},#{ip},NOW())")
    void saveH5Visit(@Param("openId") String openId, @Param("ip") String ip);

    @Select("SELECT url AS qrCode FROM t_image_poster WHERE poster_id = #{posterId}  AND `status` =0 AND type = 0")
    String selectQrCodeByPostId(Integer posterId);

    List<MerchantPoster> merchantListByEmployeeId(@Param("employeeId") Integer employeeId);
}
